public class Login {
    public String username = "wang";
    public String password = "123";
    public void loginInfo(String username,String password) throws UserNameException,PassWordException{
        if(!this.username.equals(username)){
            throw new UserNameException("用户名有问题"+username);
        }
        if(!this.password.equals(password)){
            throw new PassWordException("密码有问题"+password);
        }
        System.out.println("登陆成功！");
    }

    public static void main(String[] args) {
        Login login = new Login();
        try {
            login.loginInfo("wang","1234a");
        }catch (UserNameException e){
            e.printStackTrace();
            System.out.println("捕获了UserNameException");
        }catch (PassWordException e){
            e.printStackTrace();
            System.out.println("捕获了PassWordException");
        }
    }
}
